package com.soryin.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Query;

import com.soryin.dao.OpenPlatformDao;
import com.soryin.entity.OpenPlatform;

/**
 * 开放平台 数据库 实现
 * @author Hello_海生
 * @date 2014年3月21日
 */
public class OpenPlatformDaoImpl extends BaseDaoImpl<OpenPlatform> implements OpenPlatformDao {

	@Override
	public OpenPlatform selectOpenPlatformByTypeAndSid(String type,String sid){
		OpenPlatform op=new OpenPlatform();
		Query query=this.getSession().createQuery("from OpenPlatform where type='"+type+"' and sid='"+sid+"'");
		if(query.list().size()>0) op=(OpenPlatform)query.list().get(0);
		return op;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<OpenPlatform> selectOpenPlatformByUserId(int id) {
		List<OpenPlatform> list=new ArrayList<OpenPlatform>();
		Query query=this.getSession().createQuery("from OpenPlatform where userId="+id);
		list=(List<OpenPlatform>)query.list();
		return list;
	}

}
